<#--
  // 百度富文本
 -->
<#macro ueditor name
                id = ""
                bizType=""
                bizId=""
                value = ""
                helpTip = ""  <#--帮助提示 -->
                readonly = false 	<#-- 是否只读模式 -->
                maxlength =  10000 <#-- 最大输入长度默认不限-->
                height = 300 <#-- 高度-->
                template = false <#-- 控件是否做template用-->
                toolbars = "all" <#--工具类 默认所有 -->
                type = ["content"] <#--获取数据类型 html (整个html的内容), content (内容), txt(纯文本), plaintxt (带格式的纯文本)-->
                >
    <#local  Assname="${id}"/>
    <#if name != "">
        <#local Assname="${name}"/>
    </#if>
    <#local AssId=""/>
    <#if id == "">
        <#local AssId="${Assname}"/>
    <#else>
        <#local AssId="${id}"/>
    </#if>
    <input id="<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>" name="<#if name != "">${name}<#else>${AssId}</#if>" value="<#if value != "">${value}</#if>" type="hidden"/>
    <script id="<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>ContentUE" type="text/plain" style="width:100%;height:${height}px;"></script>
    <@compress single_line=true>
    <script type="text/javascript">
        $(function() {
            if (window.UEDITOR_CONFIG === undefined) {
                opt.error("ueditor 插件未引入,请模板引擎header Lis中引入!!");
                return;
            }
            var remarksUE_<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if> = UE.getEditor('<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>ContentUE', {
                serverUrl: window.UEDITOR_CONFIG.serverUrl+"?bizType=${bizType}&bizId=${bizId}",
                <#--maximumWords: ${maxlength},-->
                readonly: ${readonly?string('true','false')},
                initialFrameHeight: ${height}
                <#if toolbars == "text" && !readonly>
                ,toolbars: [[
                    'undo', 'redo', '|','bold', 'italic', 'underline','forecolor','removeformat',
                    'backcolor','fontfamily', 'fontsize','insertorderedlist', 'insertunorderedlist','|','justifyleft', 'justifycenter', 'justifyright', 'justifyjustify'
                ]]
                ,elementPathEnabled: false
                ,wordCount: false
                <#elseif readonly>
                ,toolbars: []
                ,elementPathEnabled: false
                ,wordCount: false
                ,enableContextMenu: false
                <#elseif toolbars != "text" && toolbars!= "all" && !readonly >
                ,toolbars: [[
                    'undo', 'redo', '|','bold', 'italic', 'underline','forecolor','removeformat',
                    'backcolor','fontfamily', 'fontsize','insertorderedlist', 'insertunorderedlist','|','justifyleft', 'justifycenter', 'justifyright', 'justifyjustify'
                    ,'|',${toolbars}
                ]]
                ,elementPathEnabled: false
                ,wordCount: false
                </#if>
            });
            /* 更新编辑器内容  remarksUE.updateContent();*/
            remarksUE_<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>.updateContent = function(){
                var <#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>_html = "";
                if (!remarksUE_<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>.hasContents()){
                    $('#<#if id == "">${name}<#else>${id}</#if>').val("").change();
                }else{
                    <#if type[0] == "html">
                    <#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>_html = remarksUE_<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>.getAllHtml().replace('<!--HTML-->','');
                    <#elseif type[0] == "content">
                    <#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>_html = remarksUE_<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>.getContent().replace('<!--HTML-->','');
                    <#elseif type[0] == "txt">
                    <#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>_html = remarksUE_<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>.getContentTxt().replace('<!--HTML-->','');
                    <#elseif type[0] == "plaintxt">
                    <#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>_html = remarksUE_<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>.getPlainTxt().replace('<!--HTML-->','');
                    </#if>
                    $('#<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>').val(<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>_html).change();
                }
                if (typeof window.webuploaderRefresh == 'function'){
                    <#assign res="" />
                    <#list type as x>
                    <#if x != type[0] >
                    <#if x == "html">
                    var <#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>_html${x?index} = remarksUE_<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>.getAllHtml().replace('<!--HTML-->','');
                    <#elseif x == "content">
                    var <#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>_html${x?index} = remarksUE_<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>.getContent().replace('<!--HTML-->','');
                    <#elseif x == "txt">
                    var <#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>_html${x?index} = remarksUE_<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>.getContentTxt().replace('<!--HTML-->','');
                    <#elseif x == "plaintxt">
                    var <#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>_html${x?index} = remarksUE_<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>.getPlainTxt().replace('<!--HTML-->','');
                    </#if>
                    <#assign res= res + ',<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>_html${x?index}' />
                    </#if>
                    </#list>
                    window.webuploaderRefresh("<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>",<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>_html${res});
                }
            };
            /* 编辑器加载完成事件*/
            remarksUE_<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>.ready(function(){
                remarksUE_<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>.execCommand('insertHtml', $("#<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>").val());
                remarksUE_<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>.addListener('contentchange', function(){
                    remarksUE_<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>.updateContent();
                });
                remarksUE_<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>.addListener('focus blur', function(type, arg1, arg2){
                    if(type == 'focus'){
                        $('#<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>ContentUE').addClass('_focus');
                    }
                    if(type == 'blur'){
                        $('#<#if !template>${AssId?replace(".","_")}<#else>${AssId}</#if>ContentUE').removeClass('_focus');
                    }
                });
            });
        });
    </script>
    </@compress>
    <#if helpTip!=""><span class="help-block m-b-none"><i class="fa fa-info-circle" style="color: red"></i>${helpTip}</span></#if>
</#macro>